package com.jianganming.facade;


public class FacadeTest3 {
    public static void main(String[] args) {
        SmartSpeaker smartSpeaker = new SmartSpeaker();
        smartSpeaker.say("我放学了");
    }
}

class Light{
    public void on(){
        System.out.println("开灯");
    }
    public void off(){
        System.out.println("关灯");
    }
}

class Tv{
    public void on(){
        System.out.println("开电视");
    }
    public void off(){
        System.out.println("关电视");
    }
}

class Fan{
    public void on(){
        System.out.println("开风扇");
    }
    public void off(){
        System.out.println("关风扇");
    }
}

class SmartSpeaker{
    private Light light;
    private Tv tv;
    private Fan fan;
    public SmartSpeaker(){
        light = new Light();
        tv = new Tv();
        fan = new Fan();
    }

    public void say(String order){
        if(order.contains("睡觉")){
            sleep();
        }else if(order.contains("起床")){
            getUp();
        }else {
            System.out.println("听不懂你说啥");
        }
    }
    private void sleep(){
        System.out.println("开始睡觉了");
        light.off();
        tv.off();
        fan.on();
    }

    private void getUp(){
        System.out.println("起床了");
        light.on();
        tv.on();
        fan.off();
    }
}
